package com.ruoyi.qsng.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.uuid.SnowFlakeUtil;
import com.ruoyi.qsng.domain.KCheckRule;
import com.ruoyi.qsng.mapper.KCheckRuleMapper;
import com.ruoyi.qsng.service.IKCheckRuleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 打卡规则Service业务层处理
 *
 * @author kanglou
 * @date 2023-06-07
 */
@Service
public class KCheckRuleServiceImpl implements IKCheckRuleService {
    @Autowired
    private KCheckRuleMapper kCheckRuleMapper;

    /**
     * 查询打卡规则
     *
     * @param id 打卡规则主键
     * @return 打卡规则
     */
    @Override
    public KCheckRule selectKCheckRuleById(String id) {
        return kCheckRuleMapper.selectKCheckRuleById(id);
    }

    /**
     * 查询打卡规则列表
     *
     * @param kCheckRule 打卡规则
     * @return 打卡规则
     */
    @Override
    public List<KCheckRule> selectKCheckRuleList(KCheckRule kCheckRule) {
        return kCheckRuleMapper.selectKCheckRuleList(kCheckRule);
    }

    /**
     * 新增打卡规则
     *
     * @param kCheckRule 打卡规则
     * @return 结果
     */
    @Override
    public int insertKCheckRule(KCheckRule kCheckRule) {
        kCheckRule.setId(SnowFlakeUtil.getNextId());
        kCheckRule.setCreateTime(DateUtils.getNowDate());
        return kCheckRuleMapper.insertKCheckRule(kCheckRule);
    }

    /**
     * 修改打卡规则
     *
     * @param kCheckRule 打卡规则
     * @return 结果
     */
    @Override
    public int updateKCheckRule(KCheckRule kCheckRule) {
        kCheckRule.setUpdateTime(DateUtils.getNowDate());
        return kCheckRuleMapper.updateKCheckRule(kCheckRule);
    }

    /**
     * 批量删除打卡规则
     *
     * @param ids 需要删除的打卡规则主键
     * @return 结果
     */
    @Override
    public int deleteKCheckRuleByIds(String[] ids) {
        return kCheckRuleMapper.deleteKCheckRuleByIds(ids);
    }

    /**
     * 删除打卡规则信息
     *
     * @param id 打卡规则主键
     * @return 结果
     */
    @Override
    public int deleteKCheckRuleById(String id) {
        return kCheckRuleMapper.deleteKCheckRuleById(id);
    }
}
